package zb.blog.controller;

import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import zb.blog.base.bean.Result;
import zb.blog.base.global.GlobalVar;
import zb.blog.bean.CommentBean;
import zb.blog.service.IAboutMeService;
import zb.blog.service.ICommentService;
import zb.blog.service.IMessageService;

import javax.servlet.http.HttpSession;
import java.security.GeneralSecurityException;
import java.util.Map;

/**
 * @Author: BinZhang
 * @Date: 2018/5/15 22:06
 * @Description:消息和留言相关
 */
@Controller
@RequestMapping("/message")
public class MessageController {
    @Autowired
    private IMessageService iMessageservice;
    @Autowired
    private IAboutMeService iAboutMeService;

    /**
     * @Author: BinZhang
     * @Date: 2018/5/20 15:52
     * @Description:获取个人信息（留言板）
     */
    @RequestMapping("/getMessageBoard")
    @ResponseBody
    public Result getMessageBoadr() {
        return iAboutMeService.getArticleByType(2);
    }

    /**
     * @Author: BinZhang
     * @Date: 2018/5/15 22:06
     * @Description:获取消息和留言
     */
    @RequestMapping("/back/getMessage")
    @ResponseBody
    public PageInfo<CommentBean> getMessage(@RequestBody Map<String, String> param) {
        return iMessageservice.getMessage(param);
    }

    /**
     * @param status      审核状态
     * @param commentId   评论id或者留言id
     * @param isSendEmail 是否发送电子邮件
     * @param content     回复的内容
     * @Author: BinZhang
     * @Date: 2018/5/16 1:51
     * @Description:评论、留言审核和回复
     */

    @RequestMapping("/back/auditMessage")
    @ResponseBody
    public Result auditMessage(Integer status, Integer commentId, Integer isSendEmail, String content) throws GeneralSecurityException {
        return iMessageservice.auditMessage(status, commentId, isSendEmail, content);
    }
}
